import {requests} from '@/utils/axios'
import request from '@/utils/axios'

export function download_url(uid_list){
  console.log('-------------- download_url 根据传入的uids列表获取对应的手机号并且返回txt文档,uid_list=', uid_list)
  const config = {
    baseURL: 'http://localhost:8000',
    method: 'post',
    url: 'v0/accounts/download_txt',
    data: uid_list
  }
  return requests(config)
}

export function aqm_get_all_accs(){
  // console.log('aqm_get_all_accs 获取全部测试账号')
  const config = {
    baseURL: 'http://localhost:8000',
    method: 'get',
    url: 'v0/accounts/list',
  }
  return requests(config)
}

export function aqm_get_flag_accs(use_flag){
  console.log('-------------- aqm_get_flag_accs 根据使用状态获取测试账号,use_flag=', use_flag)
  const config = {
    baseURL: 'http://localhost:8000',
    method: 'get',
    url: 'v0/accounts/get_flag',
    params: {
      use_flag: use_flag
    }
  }
  return requests(config)
}

export function aqm_set_single_flag_accs(uid,use_flag){  // 注意：返回值为修改后的对应状态数据
  console.log('-------------- aqm_set_flag_accs 根据flag设置对应测试账号,uid=', uid, ',flag=',use_flag)
  const config = {
    baseURL: 'http://localhost:8000',
    method: 'put',
    url: 'v0/accounts/set_flag',
    data: {
      uid: uid,
      use_flag: use_flag
    }
  }
  return requests(config)
}

export function aqm_set_batch_flag_accs(uid_list,use_flag){  // 注意：返回值为修改后的对应状态数据
  console.log('-------------- aqm_set_batch_flag_accs 根据flag批设置对应测试账号,uid_list=', uid_list, ',flag=',use_flag)
  const config = {
    baseURL: 'http://localhost:8000',
    method: 'put',
    url: 'v0/accounts/set_batch_flag',
    data: {
      uid_list: uid_list,
      use_flag: use_flag
    }
  }
  return requests(config)
}

export function aqm_delete_acc(uid){  // 软删除方法
  console.log('-------------- 根据uid软删除测试账号，aqm_delete_acc uid=', uid)
  const config = {
    baseURL: 'http://localhost:8000',
    method: 'delete',
    url: 'v0/accounts/delete',
    params: {
      uid: uid
    }
  }
  return requests(config)
}


export function raas_import_account(params){
  // console.log('raas_import_account 导入测试账号')
  let url = '/RaaS/importAcc'
  return request(url, {
    method: 'POST',
    body: params
  })
}

export function raas_get_all_accs(params){
  // console.log('raas_get_all_accs 获取全部测试账号')
  let url = '/RaaS/listAcc'
  return request(url, {
    method: 'GET',
    params: params
  })
}

export function raas_add_account(params){
  // console.log('raas_add_account 添加测试账号')
  let url = '/RaaS/addAcc'
  return request(url, {
    method: 'POST',
    body: params
  })
}

export function raas_edit_account(params){
  // console.log('raas_edit_account 编辑测试账号')
  let url = '/RaaS/editAcc'
  return request(url, {
    method: 'POST',
    body: params
  })
}

export function raas_export_account(params){
  // console.log('raas_import_account 导出测试账号')
  let url = '/RaaS/exportAcc'
  const config = {
    baseURL: process.env.VUE_APP_BASE_API,
    method: 'get',
    url: url,
    params: params,
    responseType: 'blob'
  }
  return requests(config)
}

export function raas_delete_acc(params){  // 软删除方法
  let url = '/RaaS/delAcc'
  return request(url, {
    method: 'POST',
    body: params
  })
}

